# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=flyr
pkgver=76.4926ecc
pkgrel=1
pkgdesc='Block-based software vulnerability fuzzing framework.'
groups=('blackarch' 'blackarch-fuzzer')
arch=('x86_64' 'aarch64')
url='https://github.com/zznop/flyr'
license=('MIT')
makedepends=('git' 'scons')
source=("git+https://github.com/zznop/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  git submodule update --init

  # tmp fix until upstream fixes it
  sed -Ei \
    's|__bswap16|__bswap_16|g;s|__bswap32|__bswap_32|g;s|__bswap64|__bswap_64|g'\
    src/build.c
}

build() {
  cd $pkgname

  scons
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 755 "build/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a examples docker "$pkgdir/usr/share/$pkgname/"
}

